package com.test.fundible.fundible_02_permission;


import android.view.View;

public class PermissionInfo {

    private final int iconDrawableId;
    private final String permissionTitle;
    private int permissionDescId;

    private PermissionAdapter.PermissionHolder holder;

    private View.OnClickListener nextClickListener,denyClickListener,agreeClickListener;

    public PermissionInfo(int iconDrawableId, String permissionTitle, int permissionDescId) {
        this.iconDrawableId = iconDrawableId;
        this.permissionTitle = permissionTitle;
        this.permissionDescId = permissionDescId;
    }

    public void setHolder(PermissionAdapter.PermissionHolder holder) {
        this.holder = holder;
        initHolder();
    }

    private void initHolder(){

        if (holder==null) return;

        holder.setIcon(iconDrawableId);
        holder.setTitle(permissionTitle);
        holder.setDesc(permissionDescId);
        holder.setNextClickListener(nextClickListener);
        holder.setDenyClickListener(denyClickListener);
        holder.setAgreeClickListener(agreeClickListener);

    }

    public void setNextClickListener(View.OnClickListener onClickListener){
        this.nextClickListener = onClickListener;
    }

    public View.OnClickListener getNextClickListener() {
        return nextClickListener;
    }

    public boolean isPermissionCheck(){
        if (holder == null) return false;
        return holder.isCheck();
    }

    public void setPermissionStatus(PermissionStatus status){
        if (holder == null) return;
        holder.setPermissionStatus(status);
    }

    public void setDenyClickListener(View.OnClickListener onClickListener){
        this.denyClickListener = onClickListener;
    }

    public void setAgreeClickListener(View.OnClickListener onClickListener){
        this.agreeClickListener = onClickListener;
    }

    public void setPermissionCheck(boolean isCheck){
        if (holder!=null) holder.setCheck(isCheck);
    }

    public int getIconDrawableId() {
        return iconDrawableId;
    }

    public String getPermissionTitle() {
        return permissionTitle;
    }

    public int getPermissionDescId() {
        return permissionDescId;
    }

    public PermissionAdapter.PermissionHolder getHolder() {
        return holder;
    }
}
